import strutils, sequtils

proc isValid*(nums: string): bool =
  if not nums.allCharsInSet(Digits + {' '}): 
    return false

  var digits = nums.filterIt(it in Digits).mapIt(it.ord - '0'.ord)

  if digits.len < 2:
    return false

  var
    even = true
    sum = 0

  sum = digits.foldr:
    var c = b + a
    if even:
      c.inc(a)
      if a > 4: c.dec(9)
    even = not even
    c

  sum mod 10 == 0
